﻿Imports System.Linq
Imports TNCDAL

Public Class ContTypeController
    Private objRepository As New ContTypeRepository

    Public Function SelectAllRecord() As IQueryable(Of tblContType)
        Return objRepository.SelectAllRecord()
    End Function

    Public Function SelectRecordById(ByVal id As Integer) As tblContType
        Return objRepository.SelectRecordById(id)
    End Function

    Public Sub Insert(ByVal obj As tblContType)
        objRepository.Insert(obj)
    End Sub

    Public Sub Update(ByVal obj As tblContType)
        objRepository.Update(obj)
    End Sub

    Public Function SelectCustom(ByVal strName As String) As IQueryable
        Dim query = SelectAllRecord()

        If strName <> "" Then
            query = query.Where(Function(p) p.ContTypeName.ToLower.Contains(strName.ToLower))
        End If

        query = query.OrderBy(Function(p) p.ContTypeName)
        Return query
    End Function
End Class

